home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Java 1996 August
/
Java - Summer 1996.iso
/
kaffe-0.2
/
kaffe
/
constants.h
< prev
next >
Wrap
C/C++ Source or Header
|
1996-02-12
|
2KB
|
88 lines
/*
* constants.h
* Manage constants.
*
* Copyright (c) 1996 Systems Architecture Research Centre,
* City University, London, UK.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
* Written by Tim Wilkinson <tim@sarc.city.ac.uk>, February 1996.
*/
/* COPYRIGHT */
#ifndef __constant_h
#define __constant_h
#include <stdio.h>
#include "object.h"
#include "file.h"
/*
* Constant pool definitions.
*/
#define CONSTANT_Class 7
#define CONSTANT_Fieldref 9
#define CONSTANT_Methodref 10
#define CONSTANT_InterfaceMethodref 11
#define CONSTANT_String 8
#define CONSTANT_Integer 3
#define CONSTANT_Float 4
#define CONSTANT_Long 5
#define CONSTANT_Double 6
#define CONSTANT_NameAndType 12
#define CONSTANT_Utf8 1
#define CONSTANT_Unicode 2
#define CONSTANT_Unknown 0
#define CONSTANT_Chararray 128
typedef u2 constIndex;
typedef struct _constants {
u2 size;
u1* tags;
u4* data;
} constants;
#define STRHASHSZ 128
typedef struct _strconst {
struct _strconst* next;
struct _stringClass* string;
object obj;
char data[0];
} strconst;
#define STRING_DATA2BASE(i) (strconst*)(((int)i) - (sizeof(object)+sizeof(strconst*)+sizeof(strconst*)))
#define STRING_OBJ2DATA(i) (char*)(((int)i) + sizeof(object))
typedef struct _strpair {
struct _strpair* next;
uint32 hash;
char* s1;
char* s2;
} strpair;
/*
* Macros to take constant pools apart.
*/
#define METHODREF_CLASS(idx, pool) (pool->data[idx] & 0xFFFF)
#define METHODREF_NAMEANDTYPE(idx, pool) (pool->data[idx] >> 16)
#define CLASS_NAME(idx, pool) (pool->data[idx])
#define FIELDREF_CLASS(idx, pool) METHODREF_CLASS(idx, pool)
#define FIELDREF_NAMEANDTYPE(idx, pool) METHODREF_NAMEANDTYPE(idx, pool)
#define NAMEANDTYPE_NAME(idx, pool) METHODREF_CLASS(idx, pool)
#define NAMEANDTYPE_SIGNATURE(idx, pool) METHODREF_NAMEANDTYPE(idx, pool)
#define STRING_NAME(idx, pool) CLASS_NAME(idx, pool)
constants* readConstantPool(classFile*);
char* addStringConstant(strconst*);
strpair* addStringConstantPair(char*, char*);
strpair* lookupStringPair(char*, char*);
#endif